home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / snip9503 / stk.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-14  |  1.3 KB  |  60 lines

  1. /*
  2. ** stk.h - Stack manager (stk.c) header file.
  3. **
  4. ** By Dustin Puryear, placed into Public Domain.
  5. */
  6.  
  7. typedef struct stknode
  8. {
  9.       void           *pdata;
  10.       struct stknode *pprev;
  11. } StkNode;
  12.  
  13. typedef struct stk
  14. {
  15.       StkNode        *ptop;
  16.       unsigned       vcount;
  17. } Stk;
  18.  
  19. /*
  20. ** stkInit()
  21. **
  22. ** Precondition   - pstack points to a stk type variable.
  23. ** Postcondition  - Stack pointed to by pstack is initialized.
  24. ** Returns        - None.
  25. */
  26.  
  27. extern void stkInit(Stk *pstack);
  28.  
  29. /*
  30. ** stkPush()
  31. **
  32. ** Precondition   - pstack points to an initialized stack.
  33. **                  pdata points to data to be stored in stack.
  34. ** Postcondition  - Data contained in pdata is pushed onto the stack.
  35. ** Returns        - Non-zero if success, 0 if error.
  36. */
  37.  
  38. extern int stkPush(Stk *pstack, void *pdata);
  39.  
  40. /*
  41. ** stkPop()
  42. **
  43. ** Precondition   - ppdata points to a pointer to contain data.
  44. **                  pstack points to initialized stack.
  45. ** Postcondition  - Top of stack is pushed into ppdata (pointer).
  46. ** Returns        - Non-zero if success, 0 if error.
  47. */
  48.  
  49. extern int stkPop(void **ppdata, Stk *pstack);
  50.  
  51. /*
  52. ** stkCount()
  53. **
  54. ** Precondition   - pstack points to an intialized stack.
  55. ** Postcondition  - None.
  56. ** Returns        - Number of items on stack.
  57. */
  58.  
  59. extern unsigned stkCount(Stk *pstack);
  60.